feat(openai): route OpenAI Realtime (WebSocket) through LLM Gateway#94
Open
cosminacho wants to merge 1 commit into
Open
feat(openai): route OpenAI Realtime (WebSocket) through LLM Gateway#94cosminacho wants to merge 1 commit into
cosminacho wants to merge 1 commit into
Conversation
UiPathOpenAI / UiPathAsyncOpenAI now expose `client.realtime.connect()` exactly like the stock OpenAI SDK, opening a WebSocket to the gateway's passthrough realtime endpoint (.../vendor/<vendor>/model/<model>/realtime). The .realtime resource points websocket_base_url at the gateway, sets the S2S bearer token as api_key (sent as Authorization: Bearer on the upgrade), and injects the X-UiPath-* routing headers. Completions/embeddings are unaffected: their auth uses the httpx pipeline, and the realtime URL is built lazily on .realtime access. - openai extra now installs openai[realtime] (pulls in websockets) - langchain openai extra pulls core[openai] so realtime works from a langchain install (LangChain has no realtime chat-model abstraction) - bump core + langchain to 1.15.0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Adds OpenAI Realtime API (WebSocket) support, routed through the UiPath LLM Gateway.
UiPathOpenAI/UiPathAsyncOpenAInow exposeclient.realtime.connect()exactly like the stock OpenAI SDK:How it works
The Realtime API speaks over a WebSocket, so it can't use the existing httpx routing. A
.realtimecached-property override returns a gateway-aware resource wrapper that, onconnect():websocket_base_urlat the gateway passthrough realtime path (.../vendor/nativeopenai/model/<model>/realtime),api_key(read straight fromLLMGatewayS2SAuth.access_token; the SDK sends it asAuthorization: Beareron the WebSocket upgrade),X-UiPath-*routing headers on the upgrade.Completions/embeddings are unaffected — their auth comes from the httpx auth pipeline, and the realtime URL is built lazily only when
.realtimeis accessed (so platform/agenthub construction is untouched).Why no separate class / no LangChain wrapper
The openai-python README shows realtime works on the standard client — no subclass needed — so it's folded into the existing clients. LangChain has no realtime chat-model abstraction (langchain#28086 is still open;
ChatOpenAIhas no.realtime), so there's nothing to wrap there — realtime is used from a LangChain project by dropping down to the core client.Packages affected
Both (version together):
1.15.0: realtime clients inuipath.llm_client.clients.openai;openaiextra now installsopenai[realtime](pulls inwebsockets); helperbuild_realtime_ws_base_url.1.15.0:openaiextra now also pullsuipath-llm-client[openai]so realtime works out of the box from auipath-langchain-client[openai]install. No code change.Tests / checks
tests/core/clients/openai/test_realtime_unit.py(URL helper, lazy build, websocket_base_url + token + header wiring, default-model resolution, token refresh). Realtime is a WebSocket so it can't be VCR-recorded; end-to-end was verified manually against alpha (gpt-realtime).ruff check,ruff format --check,pyrightall clean;pytest tests→ 1968 passed, 0 failures.🤖 Generated with Claude Code